﻿<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>景点数据</title>
    <style type="text/css">
    body
    {
    	font-family:Verdana;
    	font-size:12px;
    }
        .style1
        {
            width: 90%;
        }
    </style>
</head>
<body>    
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <div>    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="sceneryID" DataSourceID="SqlDataSource1" 
            ForeColor="#333333" GridLines="None" AllowSorting="True" 
            onrowdatabound="GridView1_RowDataBound" Width="90%">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
                <asp:BoundField DataField="sceneryID" HeaderText="sceneryID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="sceneryID" >
                <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:BoundField>
                <asp:BoundField DataField="sceneryName" HeaderText="sceneryName" 
                    SortExpression="sceneryName" >
                <ItemStyle HorizontalAlign="Left" Width="10%" />
                </asp:BoundField>
                <asp:BoundField DataField="province" HeaderText="province" 
                    SortExpression="province" >
                <ItemStyle HorizontalAlign="Center" Width="10%" />
                </asp:BoundField>
                <asp:BoundField DataField="city" HeaderText="city" SortExpression="city" >
                <ItemStyle HorizontalAlign="Center" Width="10%" />
                </asp:BoundField>
                <asp:BoundField DataField="level" HeaderText="level" SortExpression="level" >
                <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:BoundField>
                <asp:BoundField DataField="imageURL" HeaderText="imageURL" 
                    SortExpression="imageURL" >
                <ItemStyle HorizontalAlign="Left" Width="15%" />
                </asp:BoundField>
                <asp:BoundField DataField="description" HeaderText="description" 
                    SortExpression="description" >
                <ItemStyle HorizontalAlign="Left" Width="20%" />
                </asp:BoundField>
                <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" >
                <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:BoundField>
                <asp:BoundField DataField="creditCardNum" HeaderText="creditCardNum" 
                    SortExpression="creditCardNum" >
                <ItemStyle HorizontalAlign="Left" Width="10%" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Edit">
                    <ItemTemplate>
                        <asp:Button ID="btnEdit" runat="server" 
                            CommandArgument='<%# Eval("sceneryID") %>' Text="Edit" Width="50px" 
                            onclick="btnEdit_Click" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Delete">
                    <ItemTemplate>
                        <asp:Button ID="btnDelete" runat="server" 
                            CommandArgument='<%# Eval("sceneryID") %>' onclick="btnDelete_Click" 
                            onclientclick="return confirm(&quot;确定删除?&quot;);" Text="Delete" Width="50px" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:SceneryConnectionString %>" 
            
            SelectCommand="SELECT [sceneryID], [sceneryName], [province], [city], [level], [imageURL], [description], [price], [creditCardNum] FROM [sceneries] ORDER BY [sceneryID]" 
            DeleteCommand="DELETE FROM [sceneries] WHERE [sceneryID] = @sceneryID" 
            InsertCommand="INSERT INTO [sceneries] ([sceneryName], [province], [city], [level], [imageURL], [description], [price], [creditCardNum]) VALUES (@sceneryName, @province, @city, @level, @imageURL, @description, @price, @creditCardNum)" 
            UpdateCommand="UPDATE [sceneries] SET [sceneryName] = @sceneryName, [province] = @province, [city] = @city, [level] = @level, [imageURL] = @imageURL, [description] = @description, [price] = @price, [creditCardNum] = @creditCardNum WHERE [sceneryID] = @sceneryID">
            <DeleteParameters>
                <asp:Parameter Name="sceneryID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="sceneryName" Type="String" />
                <asp:Parameter Name="province" Type="String" />
                <asp:Parameter Name="city" Type="String" />
                <asp:Parameter Name="level" Type="Int32" />
                <asp:Parameter Name="imageURL" Type="String" />
                <asp:Parameter Name="description" Type="String" />
                <asp:Parameter Name="price" Type="Int32" />
                <asp:Parameter Name="creditCardNum" Type="String" />
                <asp:Parameter Name="sceneryID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="sceneryName" Type="String" />
                <asp:Parameter Name="province" Type="String" />
                <asp:Parameter Name="city" Type="String" />
                <asp:Parameter Name="level" Type="Int32" />
                <asp:Parameter Name="imageURL" Type="String" />
                <asp:Parameter Name="description" Type="String" />
                <asp:Parameter Name="price" Type="Int32" />
                <asp:Parameter Name="creditCardNum" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    
        <asp:Button ID="btnNew" runat="server" onclick="btnNew_Click" Text="New" />
    
    </div>
    <div runat="server" id="sceneryDiv" class="style1">
    <table rules="rows" frame="box" width="100%" visible="false">
        <tr>
            <td style="width:30%; text-align: right;">SceneryName : </td><td>
            <asp:TextBox ID="txtsName" runat="server"></asp:TextBox>
            <asp:HiddenField ID="hidID" runat="server" />
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right;">Province : </td><td>
            <asp:TextBox ID="txtProvice" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right;">City : </td><td>
            <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right;">Level : </td><td>
            <asp:TextBox ID="txtLevel" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right;">ImageUrl : </td><td>
            <asp:TextBox ID="txtImgUrl" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right; vertical-align:top">Description : </td><td>
            <asp:TextBox ID="txtDescription" runat="server" Height="179px" 
                TextMode="MultiLine" Width="525px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right;">Price : </td><td>
            <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%; text-align: right;">CreditCardNo : </td><td>
            <asp:TextBox ID="txtCCN" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width:30%">&nbsp;</td><td>
            <asp:Button ID="btnNE" runat="server" onclick="btnNE_Click" Text="New" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" 
                onclick="btnCancel_Click" />
            </td>
        </tr>
    </table>
    </div>    
    </ContentTemplate>
    </asp:UpdatePanel>
    </form>
    </body>
</html>
